package com.github.prontera.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.github.prontera.common.filter.CurrentUserIdArgumentResolver;
import com.github.prontera.common.filter.PermissionAnnotationInterceptor;

@Configuration
public class WebConfiguration extends WebMvcConfigurerAdapter {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		registry.addInterceptor(new PermissionAnnotationInterceptor()).addPathPatterns("/**").excludePathPatterns("/static/**");
		super.addInterceptors(registry);
	}

	@Override
	public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
		argumentResolvers.add(new CurrentUserIdArgumentResolver());
		super.addArgumentResolvers(argumentResolvers);
	}

}